/**
 *	@file		mutex.h 
 *	@version	1.0a
 *	@author		rpvaras
 *
 *	This file is part of omcpp.
 *	
 *	
 *
 *	omcpp is free software: you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation, either version 3 of the License, or
 *	(at your option) any later version.
 *
 *	omcpp is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with omcpp. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __mutex_h__
#define __mutex_h__ 1

#include <omcpp/config.h>

#undef WIN32

#ifdef OMCPP_PLATFORM_WIN32
#include <windows.h>
#else
//#error omcpp mutex does not support this platform
#endif

namespace omcpp
{
	//--------------------------------------------------------
	//--------------------------------------------------------
	class mutex
	{
	public:
		mutex();
		~mutex();
	private:
		mutex(const mutex&);

	public:
		void lock();
		void release();

#ifdef OMCPP_PLATFORM_WIN32
	private:
		HANDLE _hMutex;
#endif
	};

	//--------------------------------------------------------
	//--------------------------------------------------------
	class auto_mutex
	{
	public:
		auto_mutex(mutex& mtx);
		~auto_mutex();

	private:
		mutex& _mtx;
	};
};

#endif //__mutex_h__